package light.head.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.Formula;

/**
 *	园区企业
 */
@Entity
@Table
public class ParkOrgan implements Serializable{
	private static final long serialVersionUID = -489844332368437275L;
	private Integer code;				//流水号
	private Integer oc;					//企业编号
	private String name;				//企业名称
	private String website;				//企业网址
	private Integer sort;				//排序号
	private Date ct;					//创建时间
	private Integer cu;					//创建人
	private boolean deleted;			//是否删除
	private List<ParkOrgan> list; 		//批量添加
	
	private String logo;				// 企业logo
	private List<OrganSynopsisAnnex> osaList;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	public Integer getCode() {
		return code;
	}
	@Column
	public Integer getOc() {
		return oc;
	}
	@Formula("(SELECT o.name FROM Organ o WHERE o.code = oc)")
	public String getName() {
		return name;
	}
	@Formula("(SELECT od.site FROM OrganDetails od WHERE od.oc = oc)")
	public String getWebsite() {
		return website;
	}
	@Column
	public Integer getSort() {
		return sort;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(updatable = false, nullable = false)
	public Date getCt() {
		return ct;
	}
	@Column
	public Integer getCu() {
		return cu;
	}
	@Column
	public boolean getDeleted() {
		return deleted;
	}
	@Transient
	public List<ParkOrgan> getList() {
		return list;
	}
	
	@Transient
	public String getLogo() {
		return logo;
	}
	@Transient
	public List<OrganSynopsisAnnex> getOsaList() {
		return osaList;
	}
	
	public void setCode(Integer code) {
		this.code = code;
	}
	public void setOc(Integer oc) {
		this.oc = oc;
	}
	public void setName(String name) {
		this.name = name;
	}
	public void setWebsite(String website) {
		this.website = website;
	}
	public void setSort(Integer sort) {
		this.sort = sort;
	}
	public void setCt(Date ct) {
		this.ct = ct;
	}
	public void setCu(Integer cu) {
		this.cu = cu;
	}
	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}
	public void setList(List<ParkOrgan> list) {
		this.list = list;
	}
	public void setLogo(String logo) {
		this.logo = logo;
	}
	public void setOsaList(List<OrganSynopsisAnnex> osaList) {
		this.osaList = osaList;
	}
	
	public void addList(OrganSynopsisAnnex osa) {
		if (this.osaList == null) {
			this.osaList = new ArrayList<OrganSynopsisAnnex>();
		}
		this.osaList.add(osa);
	}
}
